package de.bazinga.rotw.network;

import com.captiveimagination.jgn.event.MessageListener;
import com.captiveimagination.jgn.message.Message;
import com.jmex.game.state.GameStateManager;

import de.bazinga.rotw.game.RotwGameState;
import de.bazinga.rotw.network.message.GameMessage;

public class ServerMessageListener implements MessageListener {
	
	public ServerMessageListener() {
		
	}
	
	public void messageCertified(Message message) {
        //System.out.println("Message Certified: " + message);
    }

    public void messageFailed(Message message) {
        System.out.println("Message Failed: " + message);
    }

    public void messageReceived(Message message) {
    	if(message instanceof GameMessage) {
        	((GameMessage) message).handleMessage(
        			((RotwGameState)GameStateManager.getInstance().getChild("gameState")), message, true);
    	}
        //System.out.println("Message Received: " + message);
    }

    public void messageSent(Message message) {
        //System.out.println("Message Sent: " + message);
    }
}
